package com.hospital.controller;

import com.alibaba.fastjson.JSONObject;
import com.hospital.pojo.Item;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController("/demo/api")
@RequiredArgsConstructor
public class HospitalController {


    @PostMapping("/demo/api/reportdata") //定义了一个处理 POST 请求的端点，路径为 /api/reportdata
    //接收一个 JSON 请求体，并返回一个 Map 对象
    public Map reportdata(@RequestBody JSONObject jsonObject){ //请求体中的 JSON 数据将被自动解析为 JSONObject 对象
        String examitemen = jsonObject.getString("examitemen"); //提取 examitemen 和 machine 字段的值
        String machine = jsonObject.getString("machine");
        // 创建Map来存储数据
        Map<String, Object> dataMap = new HashMap<>();

        // 添加itemUnitPQ
        dataMap.put("itemUnitPQ", "tempor");

        // 创建sourceList并添加数据
        List<Integer> sourceList = new ArrayList<>();
        sourceList.add(93);
        sourceList.add(24);
        sourceList.add(56);
        sourceList.add(34);
        sourceList.add(65);
        dataMap.put("sourceList", sourceList);

        // 创建aiList并添加数据
        List<Integer> aiList = new ArrayList<>();
        aiList.add(80);
        aiList.add(19);
        aiList.add(87);
        aiList.add(84);
        dataMap.put("aiList", aiList);

        // 创建ewmaList并添加数据
        List<Integer> ewmaList = new ArrayList<>();
        ewmaList.add(39);
        ewmaList.add(30);
        ewmaList.add(52);
        ewmaList.add(80);
        dataMap.put("ewmaList", ewmaList);

        // 创建xfbList并添加数据
        List<Integer> xfbList = new ArrayList<>();
        xfbList.add(11);
        xfbList.add(43);
        xfbList.add(12);
        xfbList.add(34);
        xfbList.add(12);
        dataMap.put("xfbList", xfbList);

        // 创建deltaList并添加数据
        List<Integer> deltaList = new ArrayList<>();
        deltaList.add(26);
        deltaList.add(27);
        deltaList.add(35);
        dataMap.put("deltaList", deltaList);

        // 创建leftList并添加数据
        List<Integer> leftList = new ArrayList<>();
        leftList.add(71);
        leftList.add(45);
        leftList.add(64);
        leftList.add(12);
        leftList.add(54);
        dataMap.put("leftList", leftList);

        // 创建rightList并添加数据
        List<Integer> rightList = new ArrayList<>();
        rightList.add(7);
        rightList.add(40);
        rightList.add(60);
        rightList.add(92);
        dataMap.put("rightList", rightList);

        // 添加type
        dataMap.put("type", "aute velit labore");
        return dataMap;
    }

    @PostMapping("/demo/api/deviceitem")
    public List<Map> deviceitem(@RequestBody JSONObject jsonObject){
        int page = jsonObject.getIntValue("page");
        String examitemen = jsonObject.getString("examitemen");
        String machine = jsonObject.getString("machine");
        // 创建List来存储所有的Map对象
        List<Map> dataList = new ArrayList();

        // 创建第一个Map对象并添加数据
        Map map1 = new HashMap();
        map1.put("devicename", "核磁共振器");
        map1.put("itemNameCn", "蓉城项目");
        map1.put("itemNameEn", "Rongcheng Project");
        map1.put("status", "0");
        map1.put("NextPage", "1");
        map1.put("PreviousPage", "1");
        dataList.add(map1);

        // 创建第二个Map对象并添加数据
        Map map2 = new HashMap();
        map2.put("devicename", "X光机");
        map2.put("itemNameCn", "光明影像计划");
        map2.put("itemNameEn", "Guangming Imaging Initiative");
        map2.put("status", "0");
        map2.put("NextPage", "2");
        map2.put("PreviousPage", "2");
        dataList.add(map2);

        // 创建第三个Map对象并添加数据
        Map map3 = new HashMap();
        map3.put("devicename", "超声波检测仪");
        map3.put("itemNameCn", "声波探查工程");
        map3.put("itemNameEn", "Sonoprobe Exploration Project");
        map3.put("status", "1");
        map3.put("NextPage", "3");
        map3.put("PreviousPage", "3");
        dataList.add(map3);

        // 创建第四个Map对象并添加数据
        Map map4 = new HashMap();
        map4.put("devicename", "心电图机");
        map4.put("itemNameCn", "心律监测行动");
        map4.put("itemNameEn", "Cardiac Rhythm Monitoring Action");
        map4.put("status", "0");
        map4.put("NextPage", "4");
        map4.put("PreviousPage", "4");
        dataList.add(map4);

        Map map5 = new HashMap();
        map5.put("devicename", "激光眼科治疗仪");
        map5.put("itemNameCn", "光明使者行动");
        map5.put("itemNameEn", "Light Messenger Action");
        map5.put("status", "1");
        map5.put("NextPage", "5");
        map5.put("PreviousPage", "5");
        dataList.add(map5);


        return dataList;
    }


    @PostMapping("/demo/api/itemllit")
    public List itemllit(@RequestBody JSONObject jsonObject){
        String machine = jsonObject.getString("machine");
        // 创建List来存储Item对象
        List<Item> itemList = new ArrayList<>();

        // 创建Item对象并添加到List中
        itemList.add(new Item("基干速素料", "车经利和"));
        itemList.add(new Item("许即连", "却对着整"));
        itemList.add(new Item("已边参第很", "则六矿民满"));
        itemList.add(new Item("新二省报清理", "把学与按问次"));
        return itemList;
    }

    @PostMapping("/demo/api/machineList")
    public List machineList(@RequestBody JSONObject jsonObject){
        String examitemen = jsonObject.getString("examitemen");
        // 创建List来存储所有的Map对象
        List<Map<String, String>> dataList = new ArrayList<>();

        // 创建第一个Map对象并添加数据
        Map<String, String> map1 = new HashMap<>();
        map1.put("devicename", "林斯安");
        map1.put("deviceid", "87");
        dataList.add(map1);

        // 创建第二个Map对象并添加数据
        Map<String, String> map2 = new HashMap<>();
        map2.put("deviceid", "92");
        map2.put("devicename", "区什几养工群器");
        dataList.add(map2);

        // 创建第三个Map对象并添加数据
        Map<String, String> map3 = new HashMap<>();
        map3.put("devicename", "名片指各已出");
        map3.put("deviceid", "47");
        dataList.add(map3);

        // 创建第四个Map对象并添加数据
        Map<String, String> map4 = new HashMap<>();
        map4.put("devicename", "用求速结习走是");
        map4.put("deviceid", "52");
        dataList.add(map4);

        // 创建第五个Map对象并添加数据
        Map<String, String> map5 = new HashMap<>();
        map5.put("devicename", "合使方油");
        map5.put("deviceid", "58");
        dataList.add(map5);
        return dataList;
    }

    @GetMapping("/demo/api/itemstatus")
    public List  itemstatus(){
        // 创建List来存储所有的Map对象
        List<Map<String, String>> dataList = new ArrayList<>();

        // 创建第一个Map对象并添加数据
        Map<String, String> item1 = new HashMap<>();
        item1.put("num", "3");
        item1.put("status", "0");
        dataList.add(item1);

        // 创建第二个Map对象并添加数据
        Map<String, String> item2 = new HashMap<>();
        item2.put("num", "2");
        item2.put("status", "1");
        dataList.add(item2);
        return dataList;
    }

    @PostMapping("/demo/api/page0report")
    public Map page0report(@RequestBody JSONObject jsonObject){
        String examitemen = jsonObject.getString("examitemen");
        String machine = jsonObject.getString("machine");

        // 创建Map来存储所有的数据
        Map<String, Object> dataMap = new HashMap<>();

        // 创建liskeyList并添加数据
        List<String> liskeyList = new ArrayList<>();
        liskeyList.add("key1");
        liskeyList.add("key2");
        liskeyList.add("key3");
        liskeyList.add("key4");
        liskeyList.add("key5");
        liskeyList.add("key6");
        dataMap.put("liskeyList", liskeyList);

        // 创建lisvalueList并添加数据
        List<String> lisvalueList = new ArrayList<>();
        lisvalueList.add("30");
        lisvalueList.add("70");
        lisvalueList.add("50");
        lisvalueList.add("20");
        lisvalueList.add("100");
        lisvalueList.add("40");



        dataMap.put("lisvalueList", lisvalueList);

        // 创建ageList并添加数据
        List<Map<String, String>> ageList = new ArrayList<>();
        Map<String, String> ageItem = new HashMap<>();
        ageItem.put("name", "30-50岁");
        ageItem.put("value", "30");

        Map<String, String> ageItem1 = new HashMap<>();
        ageItem1.put("name", "50-70岁");
        ageItem1.put("value", "20");

        Map<String, String> ageItem2 = new HashMap<>();
        ageItem2.put("name", "10-30岁");
        ageItem2.put("value", "50");
        ageList.add(ageItem);
        ageList.add(ageItem1);
        ageList.add(ageItem2);

        dataMap.put("ageList", ageList);
        return  dataMap;
    }

    @GetMapping("/demo/api/total")
    public Map total(){
        // 创建Map来存储所有的数据
        Map<String, String> dataMap = new HashMap<>();

        // 添加数据到Map中
        dataMap.put("devicecount", "culpa");
        dataMap.put("itemcount", "qui ut amet ex commodo");
        dataMap.put("workday", "elit incididunt proident");
        return dataMap;
    }


}
